// sis puella oier
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
ll read(){
    ll xx = 0, f = 1; char ch = getchar();
    for (;!isdigit(ch); ch = getchar())f = (ch == '-' ? -1 : 1);
    for (; isdigit(ch); ch = getchar())xx = xx * 10 + ch - '0';
    return xx * f;
}
const int N = 100100, M = 1000100;
typedef long double ld;
ld calc(ld v, ld a, ld V){
    ld t = (V - v) / a;
    return t * v + t * t * a / 2;
}
int n, m, L, V, p[N];
int d[N], v[N], a[N], cnt, ans1, ans2;
vector <int> ve[N];
bool vis[N];
vector <int> tmp;
void work(int l, int r){
    int nl, nr;
    nl = lower_bound(p, p + m + 2, l) - p, nr = upper_bound(p, p + m + 2, r) - p;
    if (nl >= nr)return ;
    // cout<<nl<<" "<<nr-1<<endl;
    // assert(0 < nl && nl < m + 1 && 0 < nr && nr <= m + 1);
    vis[++cnt] = false; ve[nl].push_back(-cnt), ve[nr - 1].push_back(cnt); ++ans1;
}
void getans(){
    tmp.clear();
    // for (int i = 1; i <= m; ++i)sort(ve[i].begin(), ve[i].end());
    for (int i = 1; i <= m; ++i){
        bool fl = false;
        for (int v : ve[i])if (v < 0){
            tmp.push_back(-v);
        }
        else {
            if (vis[v] == false)fl = true;
        }
        if (fl){
            for (int v : tmp)vis[v] = true;
            tmp.clear(); ++ans2;
        }
    }
    ans2 = m - ans2;
}
void solve(){
    n = read(), m = read(), L = read(), V = read();
    for (int i = 1; i <= n; ++i){
        d[i] = read(), v[i] = read(), a[i] = read();
    } cnt = 0, ans1 = ans2 = 0;
    for (int i = 1; i <= m; ++i)p[i] = read(), ve[i].clear(); p[0] = -10, p[m + 1] = L + 10;
    int nl, nr; ld it;
    for (int i = 1; i <= n; ++i){
        if (a[i] == 0){
            if (v[i] > V)work(d[i], L);
        }
        else if (a[i] > 0){
            if (v[i] > V){work(d[i], L); continue;}
            it = d[i] + calc(v[i], a[i], V);
            if (ceil(it) == it)nl = it + 1;
            else nl = ceil(it);
            if (nl <= L)work(nl, L);
        }
        else {
            if (v[i] > V){
                it = d[i] + calc(v[i], a[i], V);
                if (floor(it) == it)nr = it - 1;
                else nr = floor(it);
                if (nr < d[i])continue;
                if (nr > L)nr = L;
                work(d[i], nr);
            }
        }
    }
    getans();
    printf("%lld %lld\n", ans1, ans2);
}
signed main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int _ = read();
    while(_--)solve();
    return 0;
}

